import asyncio

from demo.chapter04.models.model import Goods, objects


async def handler():
    # 创建数据
    # good = {
    #     "supplier": 1,
    #     "name": "52这是一条异步插入的数据",
    #     "click_num": 100,
    #     "goods_num": 666,
    #     "price": 128,
    #     "brief": "贵州茅台酒厂（集团）保健酒业有限公司生产，是以“龙”字打头的酒水。中国龙文化上下8000年，源远而流长，龙的形象是一种符号、一种意绪、一种血肉相联的情感。"
    # }

    # await objects.create(Goods, **good)

    # 查询数据
    goods = await objects.execute(Goods.select())
    for good in goods:
        print(good.id,good.name,good.price)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(handler())
